function output = importfile(filename, dataLines)
%IMPORTFILE 从文本文件中导入数据
%  OUTPUT = IMPORTFILE(FILENAME)读取文本文件 FILENAME 中默认选定范围的数据。  以表形式返回数据。
%
%  OUTPUT = IMPORTFILE(FILE, DATALINES)按指定行间隔读取文本文件 FILENAME
%  中的数据。对于不连续的行间隔，请将 DATALINES 指定为正整数标量或 N×2 正整数标量数组。
%
%  示例:
%  output = importfile("D:\ScientificResearch\2024-03-13-IGBT\output.csv", [2, Inf]);
%
%  另请参阅 READTABLE。
%
% 由 MATLAB 于 2024-04-02 12:08:08 自动生成

%% 输入处理

% 如果不指定 dataLines，请定义默认范围
if nargin < 2
    dataLines = [2, Inf];
end

%% 设置导入选项并导入数据
opts = delimitedTextImportOptions("NumVariables", 32);

% 指定范围和分隔符
opts.DataLines = dataLines;
opts.Delimiter = ",";

% 指定列名称和类型
opts.VariableNames = ["t", "VC", "IC", "Iload", "VL", "IL", "V0", "I0", "Gout0", "Jout0", "V1", "I1", "Gout1", "Jout1", "V2", "I2", "Gout2", "Jout2", "V3", "I3", "Gout3", "Jout3", "vsource", "sig0", "sig1", "sig2", "sig3", "H_sig", "V_valve", "breaktype", "iteration_count", "VarName32"];
opts.VariableTypes = ["double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "string"];

% 指定文件级属性
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";

% 指定变量属性
opts = setvaropts(opts, "VarName32", "WhitespaceRule", "preserve");
opts = setvaropts(opts, "VarName32", "EmptyFieldRule", "auto");

% 导入数据
output = readtable(filename, opts);

end